package com.study.example.gameserver.module.scene.domain;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.sparrow.common.util.FileUtil;
import com.sparrow.common.util.JsonUtil;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MapMonsterSpawnData {

    private List<MonsterSpawnPoint> list = new ArrayList<>();

    public List<MonsterSpawnPoint> getList() {
        return list;
    }

    public void setList(List<MonsterSpawnPoint> list) {
        this.list = list;
    }

    public static MapMonsterSpawnData parse(String name) {
        if (name == null) {
            return null;
        }
        File file = FileUtil.getFile("config/mapData/" + name + ".json");
        ObjectMapper objectMapper = JsonUtil.getObjectMapper();
        try {
            return objectMapper.readValue(file, MapMonsterSpawnData.class);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
